package cn.xiaolongyuan.spring.cloud.swagger2.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

@EnableSwagger2
@Component
@Primary
@Slf4j
public class DocumentationConfig implements SwaggerResourcesProvider {

    @Autowired
    Swagger2Service swagger2Service;

    @Override
    public List<SwaggerResource> get() {
        log.info("获取Swagger文档");
        return swagger2Service.fetchAll();
    }

}